<?php if (!defined('SERVER_ROOT')) {exit('No direct script access allowed');}
//header
$this->template->title = 'Quá trình lương cán bộ';
$this->template->display('dsp_header.php');
$v_NAM = $arr_filter['cbx_NAM'];
$v_THANG = $arr_filter['cbx_THANG'];
?>
 <form name="frmMain" id="frmMain" action="" method="POST">
    <?php
    echo $this->hidden('controller',$this->get_controller_url());
    echo $this->hidden('hdn_item_id','0');
    echo $this->hidden('hdn_item_id_list','');
    echo $this->hidden('hdn_dsp_single_method','dsp_single_canbo');
    echo $this->hidden('hdn_dsp_all_method','dsp_all_canbo');
    echo $this->hidden('hdn_update_method','update_canbo');
    echo $this->hidden('hdn_delete_method','delete_canbo');
    echo $this->hidden('hdn_TYPE_filter', 'MA_DON_VI');
    $v_row = 0;
    $namhientai=date('Y');
    $thanghientai=date('m');
    $n=2012;
    $v_row = 0;
    $STT = 0;
    $TRANG_THAI_THANG_LUONG= '';
    ?>
   <div id="div_filter">
         <?php while ($arr = $arr_all_trangthaithangluong->FetchRow()): ?>
            <?php
             $TRANG_THAI_THANG_LUONG=$arr['TRANG_THAI'];
            ?>
          <?php endwhile; ?>
          <?php if($TRANG_THAI_THANG_LUONG == '0'):?>
               <input class = 'button' type="button" name="btn_add_canbo" value="Tính bảng lương" onclick="tinhluong_onclick();"/>
          <?php elseif($TRANG_THAI_THANG_LUONG == '1'):?>
               <input class = 'button' type="button" name="btn_add_canbo" value="Khóa bảng lương" onclick="khoabangluong_onclick()"/>
               <input class = 'button' type="button" name="btn_add_canbo" value="Cập nhật bảng lương" onclick="capnhatluong_onclick()"/>
          <?php elseif($TRANG_THAI_THANG_LUONG == '2'):?>
               <input class = 'button' type="button" name="btn_add_canbo" value="In bảng lương" onclick="In_click()"/>
          <?php endif ?>
    NĂM <select id="cbx_NAM" name="cbx_NAM" onchange="cbx_onchange(this)"
            style="border:1px solid #96BBFA;">
                    <?php while ($n<=$namhientai): ?>
                        <?php
                         $NAM=$n;
                         $n=$n+1;
                        ?>
                         <?php if($v_NAM == $NAM):?>
                           <option value="<?php echo $NAM; ?>" selected="selected"><?php echo $NAM; ?></option>
                        <?php else:?>
                           <option value="<?php echo $NAM; ?>" ><?php echo $NAM; ?></option>
                        <?php endif ?>
                    <?php endwhile; ?>
            </select>
       THÁNG <select id="cbx_THANG" name="cbx_THANG" onchange="cbx_onchange(this)"
            style="border:1px solid #96BBFA;">
                  <option value="01" <?php if($v_THANG == '01'):?> selected="selected" <?php endif?> >01</option>
                  <option value="02" <?php if($v_THANG == '02'):?> selected="selected" <?php endif?> >02</option>
                  <option value="03" <?php if($v_THANG == '03'):?> selected="selected" <?php endif?> >03</option>
                  <option value="04" <?php if($v_THANG == '04'):?> selected="selected" <?php endif?> >04</option>
                  <option value="05" <?php if($v_THANG == '05'):?> selected="selected" <?php endif?> >05</option>
                  <option value="06" <?php if($v_THANG == '06'):?> selected="selected" <?php endif?> >06</option>
                  <option value="07" <?php if($v_THANG == '07'):?> selected="selected" <?php endif?> >07</option>
                  <option value="08" <?php if($v_THANG == '08'):?> selected="selected" <?php endif?> >08</option>
                  <option value="09" <?php if($v_THANG == '09'):?> selected="selected" <?php endif?> >09</option>
                  <option value="10" <?php if($v_THANG == '10'):?> selected="selected" <?php endif?> >10</option>
                  <option value="11" <?php if($v_THANG == '11'):?> selected="selected" <?php endif?> >11</option>
                  <option value="12" <?php if($v_THANG == '12'):?> selected="selected" <?php endif?> >12</option>
               </select>
	</div>

    <table  width="100%" class="adminlist" cellspacing="0" border="1">
        <colgroup>
            <col width="3%" />
            <col width="12%" />
            <col width="5%" />
            <col width="10%" />
            <col width="10%" />
            <col width="4%" />
            <col width="5%" />
            <col width="7%" />
            <col width="5%" />
            <col width="7%" />
            <col width="7%" />
            <col width="7%" />
            <col width="7%" />
            <col width="9%" />

        </colgroup>
        <tr>
            <th rowspan="2">STT</th>
            <th rowspan="2">Tên cán bộ</th>
            <th rowspan="2">Năm sinh</th>
            <th rowspan="2">Chức vụ</th>
            <th colspan="2">Hệ số lương hiện tại</th>
            <th colspan="3">Phụ cấp</th>
            <th rowspan="2">Tiền lương</th>
            <th colspan="3">Tiền phụ cấp</th>
            <th rowspan="2">Tổng cộng</th>
        </tr>
        <tr>
            <th>Bậc/Ngạch</th>
            <th>HSL</th>
            <th>Chức vụ</th>
            <th>Trách nhiệm</th>
            <th>Ưu đãi</th>
            <th>Chức vụ</th>
            <th>Trách nhiệm</th>
            <th>Ưu đãi</th>
        </tr>
         <?php while ($arr = $arr_all_tinhluong->FetchRow()): ?>
             <?php
             $id=1;
             $STT=$STT+1;
             $MA_CAN_BO=$arr['MA_CAN_BO'];
             $TEN_CAN_BO=$arr['TEN_CAN_BO'];
             $NAM_SINH=$arr['NAM_SINH'];
             $CHUC_VU_HIEN_TAI=$arr['CHUC_VU_HIEN_TAI'];
             $TEN_BAC_NGACH_HIEN_TAI=$arr['TEN_BAC_NGACH_HIEN_TAI'];
             $HE_SO_LUONG_HIEN_TAI=$arr['HE_SO_LUONG_HIEN_TAI'];
             $HE_SO_PHU_CAP_CHUC_VU=$arr['HE_SO_PHU_CAP_CHUC_VU'];
             $HE_SO_PHU_CAP_TRACH_NHIEM=$arr['HE_SO_PHU_CAP_TRACH_NHIEM'];
             $HE_SO_PHU_CAP_UU_DAI=$arr['HE_SO_PHU_CAP_UU_DAI'];
             $TIEN_LUONG=$arr['TIEN_LUONG'];
             $TIEN_PCCV=$arr['TIEN_PCCV'];
             $TIEN_PCTN=$arr['TIEN_PCTN'];
             $TIEN_PCUD=$arr['TIEN_PCUD'];
             $TONG_LUONG=$arr['TONG_LUONG'];
             $v_class = 'row' . ($v_row % 2);
             $v_row++;
            ?>
            <tr class="<?php echo $v_class;?>">
                <td style="text-align:center;vertical-align: middle"><?php echo $STT;?></td>
                <td ><?php echo $TEN_CAN_BO;?></td>
                <td style="text-align:center;vertical-align: middle"><?php echo $NAM_SINH;?></td>
                <td><?php echo $CHUC_VU_HIEN_TAI;?></td>
                <td><?php echo $TEN_BAC_NGACH_HIEN_TAI;?></td>
                <td style="text-align:center;vertical-align: middle"><?php if ($HE_SO_LUONG_HIEN_TAI!='0.00') echo $HE_SO_LUONG_HIEN_TAI;?></td>
                <td style="text-align:center;vertical-align: middle"><?php if ($HE_SO_PHU_CAP_CHUC_VU!='0.00') echo $HE_SO_PHU_CAP_CHUC_VU;?></td>
                <td style="text-align:center;vertical-align: middle"><?php if ($HE_SO_PHU_CAP_TRACH_NHIEM!='0.00') echo $HE_SO_PHU_CAP_TRACH_NHIEM;?></td>
                <td style="text-align:center;vertical-align: middle"><?php if ($HE_SO_PHU_CAP_UU_DAI!='0%') echo $HE_SO_PHU_CAP_UU_DAI;?></td>
                <td style="text-align:center;vertical-align: middle"><?php if ($TIEN_LUONG!=0) echo $TIEN_LUONG;?></td>
                <td style="text-align:center;vertical-align: middle"><?php if ($TIEN_PCCV!=0) echo $TIEN_PCCV;?></td>
                <td style="text-align:center;vertical-align: middle"><?php if ($TIEN_PCTN!=0) echo $TIEN_PCTN;?></td>
                <td style="text-align:center;vertical-align: middle"><?php if ($TIEN_PCUD!=0) echo $TIEN_PCUD;?></td>
                <td style="text-align:center;vertical-align: middle"><?php if ($TONG_LUONG!=0) echo $TONG_LUONG;?></td>
            </tr>
           <?php endwhile; ?>
        <?php echo $this->add_empty_rows($v_row, _CONST_DEFAULT_ROWS_PER_PAGE, 14);?>
    </table>

</form>
<script>
    function cbx_onchange(e){
       var f = document.frmMain;
       f.submit();
    }
     function tinhluong_onclick()
    {
        var f = document.frmMain;
        if (confirm('Bạn chắc chắn muốn tính bảng lương?')){
            m = $("#controller").val() + 'tinh_luong';
            $("#frmMain").attr("action", m);
            f.submit();
        }
    }
    function capnhatluong_onclick()
    {
        var f = document.frmMain;
        if (confirm('Bạn chắc chắn muốn cập nhật bảng lương?')){
            m = $("#controller").val() + 'capnhat_luong';
            $("#frmMain").attr("action", m);
            f.submit();
        }
    }
    function khoabangluong_onclick()
    {
        var f = document.frmMain;
        if (confirm('Bạn chắc chắn muốn khóa bảng lương?')){
            m = $("#controller").val() + 'khoa_luong';
            $("#frmMain").attr("action", m);
            f.submit();
        }
    }
    function In_click() {
       var thanglanhluong = $('#cbx_THANG').val();
       var namlanhluong = $('#cbx_NAM').val();
            var url = '<?php echo $this->get_controller_url(); ?>dsp_inbangluong/&thanglanhluong='+ thanglanhluong +'&namlanhluong='+namlanhluong;
       showPopWin(url, 850, 500, null);
   }
</script>
<?php $this->template->display('dsp_footer.php');